#ifndef _PROP_H
#define _PROP_H

#include <stdlib.h>
#include <mystring.h>

#include <unistd.h>

enum Effect
{
    /*武器效果*/
    Frozen=1,    //冻伤
    DoubleAttack,    //二连打
    BloodTake,        //吸血
    Disarm,  //缴械(攻击力减半)

    /*防具效果*/
    Reflex,   //反伤
    Weaken,  //手臂酸软(弱化攻击力)
    Charge, //蓄能(挨一下打，永久加一点生命值上限)

};

enum PropType
{
    Weapon,
    Defence,
    Medicament
};

struct  Prop
{
    enum  PropType type;
    void* ptr;   //指向具体对象的指针
};


typedef struct  Prop prop;
typedef struct Defence defence;
typedef struct Weapon weapon;

prop* CreatProp(enum PropType type,void* ptr);

void FreeProp(void* p,void(*Clearptr)(void*));

struct  Weapon
{
    mystr name;
    int attack;
    int id;
    enum Effect effect;
};

typedef struct Weapon weapon;

void InitWeapon(weapon* w);

mystr WeaponToString(weapon* w);

void InitArmor(defence* d);


weapon* CreatWeapon(const int id,const char* name,int attack,enum Effect effect);


struct Defence
{
    mystr name;
    int defence;
    int id;
    enum Effect effect;
};

typedef struct Defence defence;

defence* CreatDefence(const int id,const char* name,int defence,enum Effect effect);

mystr ArmorToString(defence* d);

struct Medicament
{
    mystr name;
    int HP;
    int id;
    enum Effect effect;
};

typedef struct Medicament medicament;

medicament* CreatItem(int id,const char* name,int HP,enum Effect effect);

void InitItem(medicament* i);

mystr ItemToString(medicament* m);

// void EffectConfirm(player* p, monster* m,void* ptr);   //确认装备效果



#endif

